package main

import (
	"fmt"
	"go-env-path/utils"
	"os"
	"path/filepath"
)

func main() {
	fmt.Printf("os.Args: %v\n", os.Args)
	// 识别当前是运行的发布的二进制包还是从源代码运行
	runType, err := utils.GetRunType()
	if err != nil {
		fmt.Println("GetRunType error: " + err.Error())
		return
	}
	fmt.Printf("GetRunType : %v\n", runType) // Output: SourceCode

	fmt.Println("os.Args[0] = ", os.Args[0])
	abs, _ := filepath.Abs(os.Args[0])
	fmt.Println("os.Args abs = ", abs)
	fmt.Println("os.Args dir = ", filepath.Dir(abs))
	fmt.Println("GetEunPath = ", utils.GetEunPath())
	fmt.Println("GetEunPath abs = ", utils.GetEunPathAbc())

	// 如果是从源代码运行，入口是啥，是main方法还是单元测试啥的
	sourceCodeRunType, err := utils.GetSourceCodeRunType()
	if err != nil {
		fmt.Println("GetSourceCodeRunType error: " + err.Error())
		return
	}
	fmt.Println("sourceCodeRunType = ", sourceCodeRunType) // Output: main.go

	// 识别当前是否运行在IDE中
	ide, err := utils.GetRunIDE()
	if err != nil {
		fmt.Println("GetRunIDE error: " + err.Error())
		return
	}
	fmt.Println("ide = ", ide)

}
